package com.hptpd.questionnairesurvey.repository;

import com.hptpd.questionnairesurvey.domain.Questionnaire;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * \* Created with IntelliJ IDEA.
 * \* Date: 2019/9/17
 * \*
 * \* Description:
 * \
 *
 * @author walter_long
 */
@Repository("questionnaireRep")
public interface QuestionnaireRep extends JpaRepository<Questionnaire, String> {
    /**
     * 分页列出问卷
     * @param name String
     * @param deleted Boolean
     * @param pageable Pageable
     * @return Page<Questionnaire>
     */
    Page<Questionnaire> findByNameContainsAndDeletedIsNotAndStateContainsOrderByCreatedAtDesc(String name, Boolean deleted, String state, Pageable pageable);

    Questionnaire findByNameAndDeleted(String name, boolean deleted);

    /**
     * 根据试卷id查询试卷
     * @param id
     * @return
     */
    Optional<Questionnaire> findQuestionnaireById(String id);
}
